// JScript 文件

     //纯数字输入
     function onlyNumbers()
        {
          if(!((event.keyCode>=48 && event.keyCode<=57)||(event.keyCode==8)))
          {
             event.returnValue=false;
          }
        }
        
         //去除两边空格
         function Trim(str)
         {
           return str.replace(/(^\s*)|(\s*$)/g, "");
         } 
        
        
      //提交请求时判断 
         function onlyNumbersButtonForHavePaperInternal()
        {
           var  amount  = Trim(document.getElementById('amount').value);
           var  paperNo  = Trim(document.getElementById('paperNo').value);
           var  telephone  = Trim(document.getElementById('telephone').value);
           var paymentName = Trim(document.getElementById('paymentName').value);
           var re = /^[1-9][0-9]*$/;
           var zhengFuDian = /^\d+(\.\d+)?$/;//正浮点       
          
              if(paperNo == "")
              {
               alert('Paper ID不能为空！');
               document.getElementById( 'paperNo' ).focus();
                return false;
              }
    /*       if(paperNo != "" && !re.test(paperNo))                        
               {    
                 alert("请输入合法的数字！");  
                 document.getElementById( 'paperNo' ).value = "";
                 document.getElementById( 'paperNo' ).focus();
                 return false;
               } 
             
              if(paperNo != "")
              {  
                 if(paperNo.length != 5)                        
                 {    
                    alert("文章NO为5位！");  
                    document.getElementById( 'paperNo' ).focus();
                    return false;
                 }   
              }  */
          
          
          
          
         if(amount == "")
         {
               alert('金额不能为空！');
               document.getElementById('amount').focus();
               return false;
         }
            if(amount != "" && !zhengFuDian.test(amount))                        
              {    
                 alert('请输入合法的金额！');  
                 document.getElementById('amount' ).value = "";        
                 document.getElementById( 'amount' ).focus();
                 return false;
              } 
              
            
              
     
         
         if(telephone == "")
         {
              alert('联系电话不能为空！');
              document.getElementById( 'telephone' ).focus();
                 return false;
         }
         
         if(paymentName == "")
         {
               alert('付款人姓名不能为空！');  
               document.getElementById( 'paymentName' ).focus();
               return false;
         }
       }
       
     
       
        function onlyNumbersButtonForHavePaperExternal()
        {
           var  amount  = Trim(document.getElementById('amount').value);
           var  paperNo  = Trim(document.getElementById('paperNo').value);
           var  telephone  = Trim(document.getElementById('telephone').value);
           var  paymentName = Trim(document.getElementById('paymentName').value);//
           var pName=Trim(document.getElementById('pName').value);
           var pIDNumber=Trim(document.getElementById('pIDNumber').value);
           var pTel=Trim(document.getElementById('pTel').value);
           var re = /^[1-9][0-9]*$/;
           var zhengFuDian = /^\d+(\.\d+)?$/;//正浮点       
           if(paperNo == "")
           {
            alert('Paper ID is required!');
            document.getElementById( 'paperNo' ).focus();
             return false;
           }
             
         /*      if(paperNo.length != 5)                        
               {    
                 alert("Please input the 5 digits paperNo !");  
                 document.getElementById( 'paperNo' ).value = "";
                 document.getElementById( 'paperNo' ).focus();
                 return false;
               } 
             
              if(paperNo != "" && !re.test(paperNo))                        
               {    
                 alert("Please input valid paper ID!");  
                 document.getElementById( 'paperNo' ).value = "";
                 document.getElementById( 'paperNo' ).focus();
                 return false;
               }           
          */
          
         if(amount == "")
         {
               alert('Amount is required!');
               document.getElementById('amount').focus();
               return false;
         }
         
         
          if(amount != "" && !zhengFuDian.test(amount))                        
          {    
              alert('Please input valid amount !');  
              document.getElementById('amount' ).value = "";        
              document.getElementById( 'amount' ).focus();
              return false;
           } 
         if(telephone == "")
         {
              alert('Email is required!');
              document.getElementById( 'telephone' ).focus();
                 return false;
         }
         if(paymentName == "")
         {
               alert('The name of the payment is required!');  
               document.getElementById( 'paymentName' ).focus();
               return false;
         }
         if(pName == "")
         {
               alert('The name of the Cardholder is required!');  
               document.getElementById( 'pName' ).focus();
               return false;
         }
         if(pIDNumber == "")
         {
               alert('The ID number of the Cardholder is required!');  
               document.getElementById( 'pIDNumber' ).focus();
               return false;
         }
         if(pTel == "")
         {
               alert('The telephone of the Cardholder is required!');  
               document.getElementById( 'pTel' ).focus();
               return false;
         }
         
         
         
       }
       
       
       
       
       
       
       function textCounter(field, maxlength)
       {
         if (field.value.length > maxlength)
         {
            field.value = field.value.substring(0, maxlength);
         }
       }
       
//保留小数点后两位 自动填充
function Transfer(textObject)
{
 var _value= parseFloat(textObject.value);
 if(isNaN(_value))
     {
         return;
     }
 textObject.value = _value.toFixed(2);
}

//只能输入小数点后两位
function CheckTwoWordAfterPoint(textObject)
{
 var _value = textObject.value;
 var kc=window.event.keyCode;
 
 if((kc<48 || event.keyCode>57) && kc!=46 || /\.\d\d$/.test(_value))
   event.returnValue=false
}

//清除左右的空格
function Clear(textObject)
{
  var _value = textObject.value;

  textObject.value = _value.replace(/[^\w\.\/]/ig,'');
}